<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Componentes do Repositório</title>
	</head>
	<body>
		<h1>Componentes do Repositório</h1>
		<a href="<c:url value="/repository/component/new" />">Cadastrar novo componente</a>
		<table border="1">
			<tr>
				<th>Nome</th>
				<th>Descrição</th>
				<th>Versão</th>
				<th>MD5</th>
				<th>Tamanho</th>
				<th>Data</th>
				<th>Deletar</th>
				<th>Baixar</th>
			</tr>
			<c:if test="${!empty componentList}">
				<c:forEach var="cmp" items="${componentList}">
					<tr>
						<td>${cmp.name}</td>
						<td>${cmp.description}</td>
						<td>${cmp.version}</td>
						<td>${cmp.md5hash}</td>
						<td>${cmp.size}</td>
						<td>${cmp.insertionDate}</td>
						<td>
							<form method="post" action="<c:url value="/repository/component/${cmp.id}" />">
								<input type="hidden" name="_method" value="DELETE" />
								<input type="submit" value="Deletar" />
							</form>
						</td>
						<td>
							<form method="get" action="<c:url value="/repository/component/${cmp.id}/download" />">
								<input type="submit" value="Baixar" />
							</form>
						</td>
					</tr>
				</c:forEach>
			</c:if>
			<c:if test="${empty componentList}">
				<tr>
					<td colspan="8">Nenhum componente cadastrado.</td>
				</tr>
			</c:if>
		</table>
	</body>
</html>